﻿#pragma once
#include"Common.h"

//定义一个CentralCache类,类里面放的是SpanList*对象
//这个CentralCache要定义为单例
class CentralCache
{
public:
	//获取单例
	static CentralCache* GetInstance()
	{
		return &_singleton;
	}


	//为threadCache向Central申请内存
	 size_t FetchRangeObj(void*& start, void*& end, size_t batchNum, size_t size);
	 Span* GetOneSpan(Spanlist* splist, size_t sz);
	 // 将⼀定数量的对象释放到span中
	 void ReleaseListToSpans(void* start, size_t byte_size);


private:
	CentralCache() {};//不能删除只能私有
	CentralCache(const CentralCache&) = delete;
	CentralCache&operator =(CentralCache&) = delete;
	Spanlist _List[Nspan];
	static CentralCache _singleton;
};
